<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

class CreateReportsTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('reports', function (Blueprint $table) {
            $table->bigIncrements('id');
            $table->integer('mall_id')->comment('租户ID');
            $table->string('foot_puid')->comment('芯迈合作编码');
            $table->string('foot_rid')->index()->comment('芯迈报告ID');
            $table->tinyInteger('sync_status')->default(0)->comment('是否同步平台 -1失败 0否 1是');
            $table->tinyInteger('sync_lock')->default(0)->comment('是否lock 0否 1是');
            $table->string('sync_msg')->default('')->comment('同步返回信息');
            $table->integer('wxuser_id')->default(0)->index()->comment('用户ID');
            $table->string('wx_openid')->default('')->index()->comment('微信OPENID');
            $table->string('wx_ticket')->default('')->index()->comment('微信票据ID');
            $table->unique(['foot_puid','foot_rid'],'idx_uid');
            $table->timestamps();
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('reports');
    }
}
